package com.yaozheng.vocationaltraining.view;

import net.sf.json.JSONObject;

import org.androidannotations.annotations.Click;
import org.androidannotations.annotations.EViewGroup;
import org.androidannotations.annotations.ViewById;

import com.yaozheng.vocationaltraining.R;
import com.yaozheng.vocationaltraining.utils.Constants;
import com.yaozheng.vocationaltraining.utils.TypeUtils;

import android.content.Context;
import android.content.Intent;
import android.util.AttributeSet;
import android.widget.LinearLayout;
import android.widget.TextView;

/**
 * 百问百答一项view
 * 
 * @author Administrator
 */
@EViewGroup(R.layout.item_hundred_questions_encyclopedia)
public class HundredQuestionsEncyclopediaItemView extends LinearLayout {
	@ViewById
	TextView titleTextView;

	public HundredQuestionsEncyclopediaItemView(Context context,
			AttributeSet attrs, int defStyleAttr) {
		super(context, attrs, defStyleAttr);
		// TODO Auto-generated constructor stub
	}

	public HundredQuestionsEncyclopediaItemView(Context context,
			AttributeSet attrs) {
		super(context, attrs);
		// TODO Auto-generated constructor stub
	}

	public HundredQuestionsEncyclopediaItemView(Context context) {
		super(context);
		// TODO Auto-generated constructor stub
	}

	@Click(R.id.itemRootView)
	public void enterNewsDetail() {
		Intent intent = new Intent();
		intent.setClassName(getContext(),
				Constants.NEWSDETAILACTIVITY_CLASS_NAME);
		intent.putExtra("title", "百问百答");
		getContext().startActivity(intent);
	}

	public void loadData(JSONObject itemJsonObject, int position) {
		titleTextView.setText(TypeUtils
				.getJsonString(itemJsonObject, "subject"));
	}

}
